/**
 * 
 */
package ua.kpi.javatrainee6.model.curriculum;

import ua.kpi.javatrainee6.model.people.*;
import ua.kpi.javatrainee6.model.utils.Address;

/**
 * Subject entity, contains professor and title fields 
 */
public final class Subject {
	
	private static int id;
	private String title;
	private Professor professor;
	
	/**
	 * Main constructor
	 */
	public Subject(String title, int numberOfHours, Professor professor) {
		this.title = title;
		this.professor = professor;
	}
	
	/**
	 * Optional constructor, forms subjects like {subject1, ...}, {subject2, ...}
	 * Will be deleted for the next modules
	 */
	public Subject(Professor professor) {
		id++;
		title = "subject" + id;
		this.professor = professor;
	}
	
	public Professor getProfessor() {
		return professor;
	}
	
	public String getTitle() {
		return title;
	}
	
	public String toString() {
		return String.format("Subject name: %s, Professor - %s;", title, professor.getShortDescription());
	}
	
	@Override
	public boolean equals(Object otherObject) {
		if (this == otherObject) {
			return true;
		}
		if (otherObject == null) {
			return false;
		}
		if (! (otherObject instanceof Address)) {
			return false;
		}
		Subject other = (Subject) otherObject;
		return (title.equals(other.title) && professor.equals(other.professor));                             
	}
	
	public void performAssessment(Student student) {
		professor.performAssessment(student, this);
	}
}

